<template>
	<view class="u-p-30">
		<u-navbar title="反馈" :background="{ background: '#a0cfff' }" title-color="#FFFFFF"></u-navbar>
		<view>选项</view>
		<view class="u-m-t-20">
			<u-radio-group v-model="value" @change="radioGroupChange" :wrap="true" shape="square">
				<u-radio @change="radioChange" v-for="(item, index) in list" :key="index" :name="item.name"
					:disabled="item.disabled">
					{{item.name}}
				</u-radio>
			</u-radio-group>
		</view>
		<view class="u-m-t-20">描述</view>
		<view class="u-m-t-20">
			<u-input v-model="content" type="textarea" :border="true" />
		</view>
		<view class="u-m-t-30">
			<u-button type="error" @click="sumbit()">提交</u-button>
		</view>
	</view>
</template>

<script>
	import helper from '../../common/helper.js'
	export default {
		data() {
			return {
				list: [{
						name: '卡了',
						disabled: false
					},
					{
						name: '加载数据慢',
						disabled: false
					},
					{
						name: '不好用',
						disabled: false
					}
				],
				// u-radio-group的v-model绑定的值如果设置为某个radio的name，就会被默认选中
				value: 'orange',
				content: ''
			}
		},
		methods: {
			// 选中某个单选框时，由radio时触发
			radioChange(e) {
				// console.log(e);
			},
			// 选中任一radio时，由radio-group触发
			radioGroupChange(e) {
				// console.log(e);
			},
			sumbit(){
				let that = this
				let user = uni.getStorageSync("user")
				let data = {
					type: that.value,
					content: that.content,
					userId: user.id
				}
				that.postRequest(helper.addFeebdack,data).then(res => {
					if (res.data.flag == "200") {
						uni.showToast({
							title: '添加成功',
							icon: 'none',
							duration: 2000
						})
					} else {
						uni.showToast({
							title: '添加失败',
							icon: 'none',
							duration: 2000
						})
					}
				})
			}
		}
	}
</script>

<style>

</style>
